<?php
@session_start();

extract($_REQUEST);

require_once "../lib/config.php";
require_once "../lib/functions.php";
require_once "../lib/pdomanager.php";
require_once "../lib/paginate_class.php";

$pdodbobj=new DB();
$pdodbobj->dbname=DBNAME;
$pdodbobj->hostname=HOST;
$pdodbobj->dbusername=USERNAME;
$pdodbobj->dbpassword=PASSWORD;
$pdodbobj->dbtype=TYPE;
$pdodbobj->portnumber=PORTNUMBER;

$connstatus=$pdodbobj->connect();

if(isset($day) && $day>0 && isset($month) && $month>0 && isset($year) && $year>0 && isset($captcha) && isset($Email_ID))
{
    $dateflag=checkdate($month,$day,$year);
    
    $selecquery="select User_ID from af_users where Email_ID=:emailid";
    $usersinfo=$pdodbobj->fetch_array($pdodbobj->query($selecquery,array(":emailid"=>$Email_ID)));
    
    if($dateflag==false)
    {
        echo "Invalid Date";
        exit;
    }
    else if(count($usersinfo)>0)
    {
        echo "Already Exists Emailid";
        exit;
    }
    else if($captcha!=$_SESSION['captcha'])
    {
        echo "Captcha Mismatched";
        exit;
    }
    else {
        echo "Success";
        exit;
    }
}
else
{
    echo "Non Valid Input";
}
?>